import router from "./routerCorfig";
import {BrowserRouter,Routes,Route,Navigate} from 'react-router-dom'
import {RouterList} from '../utils/type'
import {Suspense} from 'react'

const RouterView=()=>{
    const Router=(arr:RouterList[])=>{
        return arr&&arr.map((item,index)=>{
            return <Route key={index} path={item.path} element={item.element?<item.element/>:<Navigate to={item.to}/>}>
                {
                    item.children&&(Router(item.children))
                }
            </Route>
        })
    }
    return (
        <Suspense fallback={<div>loading...</div>}>
            {/* basename="poster2" */}
            <BrowserRouter basename="poster2">
                <Routes>
                    {Router(router)}
                </Routes>
            </BrowserRouter>
        </Suspense>
    )
}


export default RouterView